import { INestApplication } from '@nestjs/common'
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'

export function setupSwagger(app: INestApplication<any>, port: number) {
  const swaggerCDN = `http://localhost:${port}/static-swagger-ui`
  const config = new DocumentBuilder()
    .setTitle('Easy Mock Electron WEB API')
    .setDescription('')
    .setVersion('1.0')
    //   .addTag('cats')
    .build()
  const document = SwaggerModule.createDocument(app, config)
  SwaggerModule.setup('/swagger-ui', app, document, {
    customCssUrl: [`${swaggerCDN}/swagger-ui.css`],
    customJs: [`${swaggerCDN}/swagger-ui-bundle.js`, `${swaggerCDN}/swagger-ui-standalone-preset.js`],
  })
}
